home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / gnuplot / contrib / campbell / gsr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-27  |  3.1 KB  |  112 lines

  1. /* gsr.h  -- header used with Gnuplot graphics support routines. */
  2. #ifndef INCgsr
  3. #define INCgsr
  4.  
  5. /*-
  6.    gnuplot Graphics Support Routines header file.  This file is
  7.    required (needs to be included) by users of the gnuplot Graphics 
  8.    Support library: gsr.c
  9. -*/
  10.  
  11. /* 
  12.    Defines required by users of the Gnuplot Graphics Support Routines
  13. */
  14. #include <stdio.h>
  15. #include <math.h>
  16. #ifndef INCgtplot
  17. #include "gtplot.h"
  18. #endif
  19.  
  20. #ifndef max        /* Lattice C has max() in math.h, but shouldn't! */
  21. #define max(a,b) ((a > b) ? a : b)
  22. #endif
  23.  
  24. #ifndef min
  25. #define min(a,b) ((a < b) ? a : b)
  26. #endif
  27.  
  28.  
  29. /* Gnuplot Graphic Support Routine Globals: */
  30.  
  31. /* File pointer being used by the term routines. */
  32. #define GSRoutfile GToutfile
  33.  
  34. #ifdef GSR_OWNER
  35.  
  36. /* Define the boundary of the plot
  37.  * These are computed at each call to gnu_init(), and are constant over
  38.  * the period of one plot. They must change when the term
  39.  * type changes (requiring a call to gnu_init()).
  40.  */
  41. int GSRxleft, GSRxright, GSRybot, GSRytop;
  42. BOOLEAN GSRlogx, GSRlogy;
  43.  
  44. /*
  45.    Value where the yaxis is located (used by IMPULSE lines).
  46. */
  47. int GSRxaxis_y;
  48.  
  49. /*
  50.    Value of the point and line types in use (especially for gsr_curve())
  51. */
  52. int  GSRpoint_type = 0, GSRline_type = 0;
  53.  
  54. /* Boundary and scale factors, in user coordinates */
  55. double GSRxmin, GSRxmax, GSRymin, GSRymax;
  56. double GSRxscale, GSRyscale;
  57. float GSRxtic, GSRytic;
  58. char *GSRxformat = "%g", *GSRyformat = "%g";
  59. #else
  60.  
  61. /*-
  62.    Gnuplot Graphics Support Routine externals (available while using package):
  63.  
  64.    GSRxleft, GSRxright -- location of left, right, top, and bottom sides 
  65.    GSRybot, GSRytop       of the plot border in terminal units.
  66.  
  67.    GSRlogx, GSRlogy    -- flags indicating the x or y dimension is log scale.
  68.  
  69.    GSRxaxis_y          -- location of the yaxis (used for IMPULSE plotting).
  70.  
  71.    GSRpoint_type       -- Current point type (usually at least -1 - 6 available)
  72.    GSRline_type        -- Current line type  (-2 - 12 on some terminals)
  73.  
  74.    GSRxmin, GSRxmax,   -- maximum and minimum values expected in user
  75.    GSRymin, GSRymax       coordinates for X and Y coordinates.
  76.  
  77.    GSRxscale,          -- scaling factors to use to change from user
  78.    GSRyscale;             coordinates back to terminal coordinates.
  79.  
  80.    GSRxtic, GSRytic    -- tic width in user coordinates.
  81.  
  82.    GSRxformat,         -- format strings to use with x and y tic values
  83.    GSRyformat;            (default is "%g")
  84. -*/
  85.  
  86. extern int GSRxleft, GSRxright, GSRybot, GSRytop;
  87. extern BOOLEAN GSRlogx, GSRlogy;
  88. extern int GSRxaxis_y;
  89. extern int  GSRpoint_type, GSRline_type;
  90. extern double GSRxmin, GSRxmax, GSRymin, GSRymax;
  91. extern double GSRxscale, GSRyscale;
  92. extern float GSRxtic, GSRytic;
  93. extern char *GSRxformat, *GSRyformat;
  94. /*- end of GSR external definitions. -*/
  95.  
  96. #endif
  97.  
  98. /*-
  99.    gsr_map_x(x)
  100.    Macro to map user coordinate x to screen coordinate.
  101.  
  102.    gsr_map_y(y)
  103.    Macro to map user coordinate y to screen coordinate.
  104.  
  105.    These macros map from user to terminal coordinates (maps floating
  106.    point x or y to screen
  107. -*/
  108. #define gsr_map_x(x) (int)(GSRxleft+(x-GSRxmin)*GSRxscale+0.5) 
  109. #define gsr_map_y(y) (int)(GSRybot+(y-GSRymin)*GSRyscale+0.5)
  110.  
  111. #endif
  112.